package com.zzy.ymcc.feign;


import com.zzy.ymcc.domain.Login;
import com.zzy.ymcc.enums.GlobalExceptionCode;
import com.zzy.ymcc.result.JSONResult;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;


@Slf4j
@Component
public class LoginServiceFallbackFactory implements FallbackFactory<LoginService> {

    @Override
    public LoginService create(Throwable e) {
        e.printStackTrace();
        log.error("uaa服务发生异常，触发熔断，触发类为：LoginService，异常信息为：{}", e.getMessage());
        return new LoginService() {
            @Override
            public JSONResult saveOrUpdate(Login login) {
                return JSONResult.error(GlobalExceptionCode.ERROR);
            }
        };
    }
}
